package lianxi;

import java.util.HashMap;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2023-03-24
 * Time: 22:56
 */
public class Solution3 {
    public static void main(String[] args) {
        //二维前缀和 ( 计算子矩阵的和)
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        int [][]arr = new int[n+1][m+1];
        int [][] s = new int[n+1][m+1];
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                arr[i][j] = sc.nextInt();
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + arr[i][j];
            }
        }
        for(int i=1;i<=q;i++){
            int x1 = sc.nextInt();
            int y1  = sc.nextInt();
            int x2  = sc.nextInt();
            int y2  = sc.nextInt();
            System.out.println( s[x2][y2] - s[x2][y1-1] - s[x1-1][y2] + s[x1-1][y1-1] );
        }
    }
}
